package com.reader.api.controller.usercenter;


import com.baomidou.mybatisplus.plugins.Page;

import com.reader.api.controller.BaseController;
import com.reader.api.entity.usercenter.User;
import com.reader.api.mapper.usercenter.UserMapper;
import com.reader.api.service.usercenter.IUserService;
import com.reader.core.entity.ResultMessageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jiahaikun
 * @since 2018-10-10
 */
@RestController
@RequestMapping("/api/user")
public class UserController extends BaseController<Object> {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private IUserService iUserService;

    @Autowired
    UserMapper userMapper;

   @GetMapping(value="getuserinfo")
   @ResponseBody
   //@RequiresPermissions("tenant:dateQuery1")
    public ResultMessageInfo getUserInfo(){
    /* User userParam=new User();
       userParam.setMobile(this.getLoginId());
       User  user=iUserService.getUserInfo(userParam);*/
       return ResultMessageInfo.ofSuccess();
    }
    /**
     * @function 分页查询数据
     *
     * @param currentPage   当前页
     * @param size   每页记录数
     * @param loginId   用户名
     * @param name   姓名
     * @return
     */
    @GetMapping("list")
    public ResultMessageInfo selectListPage(@RequestParam(value = "currentPage") int currentPage ,
                                                    @RequestParam(value = "size") int size,
                                                    @RequestParam(value = "loginId",required = false) String loginId,
                                                    @RequestParam(value = "name",required = false) String name,
                                                    @RequestParam(value = "code",required = false) String code) {
        Page<Map<String, Object>> list=iUserService.selectListPage(currentPage,size,loginId,name,code);
        return ResultMessageInfo.ofSuccess(list);
    }

}

